<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="./WEB-INF/faces/newTemplate.xhtml">
        <ui:param name="title_text" value="View Products" />
        <ui:param name ="headText" value ="View Products" />
        <ui:define name="content">


            <h:form rendered="#{userSessionBean.loggedIn}">

                <div class="tableOuter">

                    <div class="tableInner">
                        <p:dataTable var="product" value="#{viewProductsBackingBean.products}">
                            <p:column sortBy="#{product.id}">
                                <f:facet name="header">ID</f:facet>
                                <h:outputText value="#{product.id}"/>
                            </p:column>
                            <p:column sortBy="#{product.modell}">
                                <f:facet name="header">Name</f:facet>
                                <h:outputText value="#{product.modell}"/>
                            </p:column>
                            <p:column sortBy="#{product.make}">
                                <f:facet name="header">Product Category</f:facet>
                                <h:outputText value="#{product.make}"/>
                            </p:column>
                            <p:column sortBy="#{product.price}">
                                <f:facet name="header">Price</f:facet>
                                <h:outputText value="#{product.price}"/>
                            </p:column>
                            <p:column sortBy="#{product.year}">
                                <f:facet name="header">Year</f:facet>
                                <h:outputText value="#{product.year}"/>
                            </p:column>
                            <p:column sortBy="#{product.mileage}">
                                <f:facet name="header">Mileage</f:facet>
                                <h:outputText value="#{product.mileage}"/>
                            </p:column>
                            <p:column sortBy="#{product.sold}">
                                <f:facet name="header">Sold</f:facet>
                                <h:outputText value="#{product.sold}"/>
                            </p:column>
                            <!-- <p:column sortBy="">
                                 <f:facet name="header">Image</f:facet>
                                 <h:graphicImage id="image"
                                                 alt="jsf-sun"
                                                 url="http://www.londontown.se/hotel/rhs-chelsea-flower-show.jpg">
                                 </h:graphicImage>           
                             </p:column>-->
                            <p:column>
                                <h:commandButton value="Remove" action="#{viewProductsController.removeProduct(product)}" /><br />
                            </p:column>
                        </p:dataTable>
                        <h:button  value="Add product" outcome="onViewAddProduct" /><br />
                    </div>
                </div>
            </h:form>
            <h:form rendered="#{!userSessionBean.loggedIn}">
                <div>You are not logged in!</div>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

